init_dates = function(start, end, min_end_date) {

    var API = {
        Settings: {
            date: new Date(),
            image: base_url + "assets/img/calendar.png",
            limiter: 0
        },
        DatePicker: {
            OnSelect: function(dateStr) {

                var arrival = API.DatePicker.GetDate(start);
                var departure = API.DatePicker.GetDate(end);

                if (arrival >= departure) {

                    var nextDayDate = API.DatePicker.NextDayDate(arrival, 1);
                    API.DatePicker.SetMinDate(end, nextDayDate);
                    API.DatePicker.SetDate(end, nextDayDate);
                } else {
                    API.DatePicker.SetMinDate(end, API.DatePicker.NextDayDate(arrival, 1));

                }
            },
            SetDate: function(input, date) {
                $('#' + input).datepicker('setDate', date);
            },
            SetMinDate: function(input, date) {
                $('#' + input).datepicker('option', 'minDate', date);
            },
            GetDate: function(input, format) {
                return $('#' + input).datepicker('getDate');
            },
            NextDayDate: function(date, noDays) {

                myDate = new Date(date);

                myDate.setDate(myDate.getDate() + noDays);
                return myDate;
            }
        }
    };

    $('#' + start).datepicker({
        minDate: API.DatePicker.NextDayDate(new Date(), API.Settings.limiter),
        dateFormat: 'dd.mm.yy',
        showOn: 'both',
        buttonImage: API.Settings.image,
        buttonImageOnly: true,
        nextText: '&raquo;',
        prevText: '&laquo;',
//        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        showOtherMonths: true,
        firstDay: 1, // Start with Monday
        onSelect: API.DatePicker.OnSelect
    });

    $('#' + end).datepicker({
        minDate: API.DatePicker.NextDayDate(new Date(), API.Settings.limiter + min_end_date),
        dateFormat: 'dd.mm.yy',
        showOn: 'both',
        buttonImage: API.Settings.image,
        buttonImageOnly: true,
        nextText: '&raquo;',
        prevText: '&laquo;',
//        dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        showOtherMonths: true,
        firstDay: 1 // Start with Monday
    })

    // SET DATES
    $(".checkinout").each(function() {
        $(this).datepicker('setDate', $(this).val());
    });

    // SET MIN DATES
    API.DatePicker.OnSelect();

}